package com.management.utils;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.List;

@ApiModel("返回结果")
public class Result<T> {
    @ApiModelProperty("结果代码")
    private Integer code;
    @ApiModelProperty("结果信息")
    private String message;
    @ApiModelProperty("返回数据")
    private T data;

    public static <T> Result<T> getInstance(Class<T> clazz){
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setMessage("请求成功");
        return result;
    }
    public static <T> Result<T> getInstance(){
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setMessage("请求成功");
        return result;
    }
    public static <T> Result<List<T>> getInstanceList(Class<T> clazz){
        Result<List<T>> result = new Result<>();
        result.setCode(200);
        result.setMessage("请求成功");
        return result;
    }

    public Integer getCode() {
        return code;
    }

    public Result setCode(Integer code) {
        this.code = code;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public Result setMessage(String message) {
        this.message = message;
        return this;
    }

    public T getData() {
        return data;

    }

    public Result setData(T data) {
        this.data = data;
        return this;
    }
}
